﻿<?php
$con=mysql_connect("localhost","root","") or die("Không thể kết nối với máy chủ!");
$sql="create database linhkienmt";
mysql_query($sql,$con);
mysql_select_db("linhkienmt",$con);
$sql1="create table sp(masp varchar(10),tensp varchar(25),maloai varchar(10),mancc varchar(10),hinhanh varchar(50),dvtinh varchar(10),soluong int,dongia float,mota varchar(100),primary key(masp))";
$sql2="create table loaisp(maloai varchar(10),tenloai varchar(25),primary key(maloai))";
$sql3="create table khachhang(makh varchar(10),cmnd varchar(25),tenkh varchar(30),diachi varchar(50),quequan varchar(50),email varchar(30),sdt varchar(15),stk varchar(30),primary key(makh,cmnd))";
$sql4="create table ncc(mancc varchar(10),tenncc varchar(25),diachi varchar(30),dienthoai varchar(12),primary key(mancc))";
$sql5="create table tintuc(matin int,chude varchar(255),ngaydua date,hinhanh varchar(50),noidung varchar(255),primary key(matin))";
$sql6="create table admin(ten varchar(50),mk varchar(30),primary key(ten))";
$sql7="create table gopy(magy varchar(10),hoten varchar(25),diachi varchar(30),dienthoai varchar(15),email varchar(50),noidung varchar(255),primary key(magy))";
$sql8="create table hdn(mahdn varchar(10),mancc varchar(10),manv varchar(10),ngaynhap date,tongtien float,primary key(mahdn))";
$sql9="create table hdx(mahdx varchar(10),makh varchar(10),manv varchar(10),ngayxuat date,trangthai varchar(50),primary key(mahdx))";
$sql10="create table dhdn(mahdn varchar(10),masp varchar(10),soluong int,dongia float,primary key(mahdn,masp))";
$sql11="create table dhdx(mahdx varchar(10),masp varchar(10),soluong float,dongia float,primary key(mahdx,masp))";
$sql12="create table nv(manv varchar(10),tennv varchar(10),ns date,qq varchar(50),sdt varchar(15),primary key(manv))";
mysql_query($sql1,$con);
mysql_query($sql2,$con);
mysql_query($sql3,$con);
mysql_query($sql4,$con);
mysql_query($sql5,$con);
mysql_query($sql6,$con);
mysql_query($sql7,$con);
mysql_query($sql8,$con);
mysql_query($sql9,$con);
mysql_query($sql10,$con);
mysql_query($sql11,$con);
mysql_query($sql12,$con);
mysql_close($con);
echo"Đã tạo lập thành công";
?>